// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   XYSeries.java

package org.achartengine.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class XYSeries
	implements Serializable
{

	private String mTitle;
	private List mX;
	private List mY;
	private double mMinX;
	private double mMaxX;
	private double mMinY;
	private double mMaxY;
	private int mScaleNumber;

	public XYSeries(String s)
	{
		this(s, 0);
	}

	public XYSeries(String s, int i)
	{
		mX = new ArrayList();
		mY = new ArrayList();
		mMinX = 1.7976931348623157E+308D;
		mMaxX = -1.7976931348623157E+308D;
		mMinY = 1.7976931348623157E+308D;
		mMaxY = -1.7976931348623157E+308D;
		mTitle = s;
		mScaleNumber = i;
		initRange();
	}

	public int getScaleNumber()
	{
		return mScaleNumber;
	}

	private void initRange()
	{
		mMinX = 1.7976931348623157E+308D;
		mMaxX = -1.7976931348623157E+308D;
		mMinY = 1.7976931348623157E+308D;
		mMaxY = -1.7976931348623157E+308D;
		int i = getItemCount();
		for (int j = 0; j < i; j++)
		{
			double d = getX(j);
			double d1 = getY(j);
			updateRange(d, d1);
		}

	}

	private void updateRange(double d, double d1)
	{
		mMinX = Math.min(mMinX, d);
		mMaxX = Math.max(mMaxX, d);
		mMinY = Math.min(mMinY, d1);
		mMaxY = Math.max(mMaxY, d1);
	}

	public String getTitle()
	{
		return mTitle;
	}

	public void setTitle(String s)
	{
		mTitle = s;
	}

	public synchronized void add(double d, double d1)
	{
		mX.add(Double.valueOf(d));
		mY.add(Double.valueOf(d1));
		updateRange(d, d1);
	}

	public synchronized void remove(int i)
	{
		double d = ((Double)mX.remove(i)).doubleValue();
		double d1 = ((Double)mY.remove(i)).doubleValue();
		if (d == mMinX || d == mMaxX || d1 == mMinY || d1 == mMaxY)
			initRange();
	}

	public synchronized void clear()
	{
		mX.clear();
		mY.clear();
		initRange();
	}

	public synchronized double getX(int i)
	{
		return ((Double)mX.get(i)).doubleValue();
	}

	public synchronized double getY(int i)
	{
		return ((Double)mY.get(i)).doubleValue();
	}

	public synchronized int getItemCount()
	{
		return mX.size();
	}

	public double getMinX()
	{
		return mMinX;
	}

	public double getMinY()
	{
		return mMinY;
	}

	public double getMaxX()
	{
		return mMaxX;
	}

	public double getMaxY()
	{
		return mMaxY;
	}
}
